<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script type="text/javascript" src="<?php echo JS_PATH?>jquery.sgallery.js"></script>
<script>
    function check_repeat_listorders(){
    	var listorders = new Array();
    	var list_flag = 0;
    	$(".list_orders").each(function(i){
    		listorders[i] = $(this).val();
        });
    	var nary=listorders.sort(); 
//     	for(var i=0;i<listorders.length;i++){
//         	if (nary[i]==nary[i+1]){ 
//      		   alert("排序字段不能出现重复值："+nary[i]); 
//      		   list_flag = 1;
//         	}
//     	}
//     	if(list_flag!=1){
    		myform.action='?m=variable&c=manage&a=listorder&dosubmit=1';myform.submit();
//         }
    }

</script>
<div class="pad-lr-10">
<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td>
		<a style="float:right;" href="javascript:;" onclick="refreshDataRedis('<?php echo 'VARIABLE:*';?>');"><em>刷新数据</em></a>
		</td>
		</tr>
    </tbody>
</table>
<form name="myform" action="?m=variable&c=manage&a=del" method="post" onsubmit="return confirm('<?php echo L('del_confirm')?>')">
<div class="table-list">
<table width="100%" cellspacing="0">
	<thead>
		<tr>
			<th  align="center" width="20"><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');"></th>
			<th align="center" width="20"><?php echo L('listorder');?></th>
			<th align="center" width="30">ID</th>
			<th align="center" width="100"><?php echo L('variable_name')?></th>
			<th align="center" width="100"><?php echo L('variable_desc')?></th>
			<th align="center" width="100"><?php echo L('variable_value')?></th>
			<th align="center" width="100"><?php echo L('variable_view')?></th>
			<th align="center" width="100"><?php echo L('variable_operation')?></th>
		</tr>
	</thead>
<tbody>
<?php
foreach($variable as $k=>$v) {
?>
    <?php if(strpos($v['value'],"_")){$color_flag=explode('_', $v['value'])[1];}?>
    <tr>
		<td align="center"><input type="checkbox" value="<?php echo $v['id']?>" name="id[]"></td>
		<td align='center'><input name='listorders[<?php echo $v['id'];?>]' type='text' size='3' value='<?php echo $v['listorder'];?>' class='input-text-c list_orders'></td>
		<td align="center"><?php echo $v['id']?></td>
		<td align="center"><?php echo $v['name']?></td>
		<td align="center"><?php if(!empty($v['description'])){echo $v['description'];}else{echo "<font color='red'>(未设置)</font>";}?></td>
		<td align="center"><?php echo $v['value']?></td>
		<td align="center" style="background: <?php echo $color_flag;?>"></td>
		<td align="center">
		<a href="javascript:edit('<?php echo $v['id']?>')"><?php echo L('variable_edit')?></a> | 
		<a href="?m=variable&c=manage&a=del&id=<?php echo $v['id'];?>" onClick="return confirm('<?php echo L('del_confirm')?>')"><?php echo L('variable_del')?></a>
		
		 </td>
    </tr>
<?php
	}

?>
</tbody>
</table>

<div class="btn">
<label for="check_box"><a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('select_all')?></a>/
<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a></label> 
<input type="button" class="button" value="<?php echo L('listorder');?>" onclick="check_repeat_listorders();"/>
<input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>"/>
</div>
<div id="pages"><?php echo $pages?></div>
</div>
</form>
</div>
<script type="text/javascript">
<!--
function edit(id) {
	window.top.art.dialog({id:'edit'}).close();
	window.top.art.dialog({title:'<?php echo L('variable_edit_val')?>',id:'edit',iframe:'?m=variable&c=manage&a=edit&id='+id,width:'580',height:'420'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()});
}

window.top.$('#display_center_id').css('display','none');
//-->
</script>
</body>
</html>